package com.edu.service.impl;

import java.util.List;

import com.edu.dao.impl.UserDaoImpl;
import com.edu.entity.GreenUser;
import com.edu.entity.Reason;
import com.edu.entity.ReasonTa;
import com.edu.entity.Shi;
import com.edu.entity.ShiC;
import com.edu.entity.ShiCs;
import com.edu.entity.User;
import com.edu.entity.YuanC;
import com.edu.service.UserServlet;


public class UserServiceImpl implements UserServlet {
	UserDaoImpl userDaoImpl = new UserDaoImpl();
	@Override
		//数据展示
	public List<User> allUser() {
		// TODO Auto-generated method stub
		List<User> listUser =userDaoImpl.allUser();
		if(listUser.size()==0) {
			System.out.println("NO DATA");
		}
		return listUser;
	}
	
	//登录识别
	@Override
	public boolean queryNameAndPass(String name, String pass) {
		// TODO Auto-generated method stub
		boolean num =userDaoImpl.queryNameAndPass(name, pass);
		return num;
	}

	//数据修改
	@Override
	public boolean update(User user) {
		// TODO Auto-generated method stub
		int num=userDaoImpl.update(user);
		if(num==1) {
			return true;
		}
		return false;
	}
	
	//删除账号
	@Override
	public boolean Delete(int id) {
		// TODO Auto-generated method stub
		int num =userDaoImpl.Delete(id);
		if(num==1) {
			return true;
		}
		return false;
	}
		
	//查询所有
	@Override
	public List<User> queryByUser(User user) {
		// TODO Auto-generated method stub
		UserDaoImpl userDaoImpl = new UserDaoImpl();
		List<User> selectUser = userDaoImpl.queryByIdAll(user);
		if(selectUser.size()==0) {
			System.out.println("No DATA");
		}
		return selectUser;
	}
	

	@Override
	public List<User> absoluteQuery(int id,User user) {
		// TODO Auto-generated method stub
		UserDaoImpl userDaoImpl = new UserDaoImpl();
		List<User> selectUser = userDaoImpl.absoluteQuery(id,user);
		if(selectUser.size()==0) {
			System.out.println("No DATA");
		}
		return selectUser;
	}

	@Override
	public int InsertUser(User user) {
		// TODO Auto-generated method stub
		UserDaoImpl userDaoImpl = new UserDaoImpl();
		int num =userDaoImpl.InsertUser(user);
		return num;
	}

	@Override
	public List<User> queryByAUser() {
		// TODO Auto-generated method stub
		UserDaoImpl userDaoImpl = new UserDaoImpl();
		List<User> selectUser = userDaoImpl.queryByAUser();
		if(selectUser.size()==0) {
			System.out.println("No DATA");
		}
		return selectUser;
	}

	@Override
	public List<YuanC> queryByAYuan(YuanC yuanc) {
		// TODO Auto-generated method stub
		List<YuanC> selectUser = userDaoImpl.queryByAUser(yuanc);
		if(selectUser.size()==0) {
			System.out.println("No DATA");
		}
		return selectUser;
	}

	@Override
	public List<ShiC> queryByAYuan(ShiC shic) {
		// TODO Auto-generated method stub
		List<ShiC> selectUser = userDaoImpl.queryByAUser(shic);
		if(selectUser.size()==0) {
			System.out.println("No DATA");
		}
		return selectUser;
	}

	@Override
	public boolean Deletes(int id) {
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
				int num =userDaoImpl.Deletes(id);
				if(num==1) {
					return true;
				}
				return false;
	}

	@Override
	public boolean DeleteShi(int id) {
		// TODO Auto-generated method stub
		int num =userDaoImpl.DeleteShi(id);
		if(num==1) {
			return true;
		}
		return false;
	}

	@Override
	public boolean updateShi(ShiC shic) {
		// TODO Auto-generated method stub
		int num=userDaoImpl.update(shic);
		if(num==1) {
			return true;
		}
		return false;
	}

	@Override
	public int InsertRe(Reason reason) {
		// TODO Auto-generated method stub
		UserDaoImpl userDaoImpl = new UserDaoImpl();
		int num =userDaoImpl.InsertRe(reason);
		return num;
	}

	@Override
	public int InsertRes(ReasonTa reasonTa) {
		// TODO Auto-generated method stub
		UserDaoImpl userDaoImpl = new UserDaoImpl();
		int num =userDaoImpl.InsertRes(reasonTa);
		return num;
	}

	@Override
	public int InsertShi(Shi shi) {
		// TODO Auto-generated method stub
		UserDaoImpl userDaoImpl = new UserDaoImpl();
		int num =userDaoImpl.InsertShi(shi);
		return num;
	}

	@Override
	public int InsertShics(ShiCs shiCs) {
		// TODO Auto-generated method stub
		UserDaoImpl userDaoImpl = new UserDaoImpl();
		int num =userDaoImpl.InsertShics(shiCs);
		return num;
	}

	@Override
	public int InsertJuan(GreenUser greenUser) {
		// TODO Auto-generated method stub
		UserDaoImpl userDaoImpl = new UserDaoImpl();
		int num =userDaoImpl.InsertJuan(greenUser);
		return num;
	}

	@Override
	public boolean UpdetJuan(GreenUser greenUser) {
		// TODO Auto-generated method stub
		boolean num=userDaoImpl.UpdetJuan(greenUser);
		return num;
	}

	@Override
	public boolean updateShis(ShiC shic) {
		// TODO Auto-generated method stub
		int num=userDaoImpl.updates(shic);
		if(num==1) {
			return true;
		}
		return false;
	}

	@Override
	public boolean UpdetYuan(YuanC yuanC) {
		// TODO Auto-generated method stub
		int num=userDaoImpl.UpdetYuan(yuanC);
		if(num==1) {
			return true;
		}
		return false;
	}

	@Override
	public boolean UpdetYuans(YuanC yuanC) {
		// TODO Auto-generated method stub
		int num=userDaoImpl.UpdetYuans(yuanC);
		if(num==1) {
			return true;
		}
		return false;
	}

	@Override
	public List<ShiC> queryByShic() {
		// TODO Auto-generated method stub
		List<ShiC> listUser =userDaoImpl.queryByShic();
		if(listUser.size()==0) {
			System.out.println("NO DATA");
		}
		return listUser;
	}

	@Override
	public List<YuanC> queryByAllYuan() {
		// TODO Auto-generated method stub
		List<YuanC> selectUser = userDaoImpl.queryByAllYuan();
		if(selectUser.size()==0) {
			System.out.println("No DATA");
		}
		return selectUser;
	}


}
